<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改人员研发')" />
    <th:block th:include="include :: datetimepicker-css" />
        <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-clock-edit" th:object="${cusPersonClock}">
            <input name="ID" th:field="*{ID}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">研发人员：</label>
                <div class="col-sm-8">
                    <input disabled th:value="*{user_name}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">参与项目：</label>
                <div class="col-sm-8">
                    <!-- <input disabled th:value="*{project_name}" class="form-control" type="text"> -->
                    <select class="form-control"
                    	required
                        name="personProjectId"
                        th:value="*{personProjectId}"
                        data-ajax--url="/system/project/select2"
                        th:data-placeholder="*{project_name}">
					</select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否倒班：</label>
                <div class="col-sm-8">
                    <select class="form-control m-b" th:value="*{type}" disabled>
                        <option value="0" th:selected="*{type == 0}">否</option>
                        <option value="1" th:selected="*{type == 1}">是</option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">开始时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="startDatetime" th:value="${#dates.format(cusPersonClock.startDatetime, 'yyyy-MM-dd HH:mm')}" class="form-control" placeholder="yyyy-MM-dd" type="text" autocomplete="off" required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">结束时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="endDatetime" th:value="${#dates.format(cusPersonClock.endDatetime, 'yyyy-MM-dd HH:mm')}" class="form-control" placeholder="yyyy-MM-dd" type="text" autocomplete="off" required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">开始研发操作人员：</label>
                <div class="col-sm-8">
                    <input disabled th:value="*{start_user_name}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">结束研发操作人：</label>
                <div class="col-sm-8">
                    <input disabled th:value="*{end_user_name}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">打卡日期：</label>
                <div class="col-sm-8">
                    <input id="clockdatetime" disabled th:value='${cusPersonClock.clockYear + "-" +cusPersonClock.clockMonth+ "-" +cusPersonClock.clockDay}' class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
        <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var prefix = ctx + "system/clock";
        $("#form-clock-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
            	
            	let ct = $('#clockdatetime').val();
            	
            	let st = $("input[name='startDatetime']").val();
            	if(st.length > 5){ st = st.substring(11)}
            	//$("input[name='startDatetime']").val(ct + " " + st);
            	
            	let et = $("input[name='endDatetime']").val();
            	if(et.length > 5){ et = et.substring(11)}
            	//$("input[name='endDatetime']").val(ct + " " + et);
            	
            	if(st >= et){
            		alert("结束打卡时间必须大于开始打卡时间");
            		return;
            	}
            	
                $.operate.save(prefix + "/edit", $('#form-clock-edit').serialize());
            }
        }

/*         $("input[name='startDatetime']").datetimepicker({
            format: "yyyy-mm-dd hh:ii",
            autoclose: true
        });

        $("input[name='endDatetime']").datetimepicker({
            format: "yyyy-mm-dd hh:ii",
            autoclose: true
        }); */
        
        $("input[name='startDatetime']").datetimepicker({
            format: "yyyy-mm-dd hh:ii",
            startView: 0,
            minView:0,
            maxView:2,
            autoclose: true
        });

        $("input[name='endDatetime']").datetimepicker({
            format: "yyyy-mm-dd hh:ii",
            startView: 0,
            minView:0,
            maxView:2,
            autoclose: true
        });
    </script>
</body>
</html>